/*
* Conditions Of Use
*
* This software was developed by employees of the Sigmatrix(Beijing) Corporation.
* This software is provided by sigmatrix as a service and is expressly
* provided "AS IS."  Sigmatrix MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED
* OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT
* AND DATA ACCURACY.  Sigmatrix does not warrant or make any representations
* regarding the use of the software or the results thereof, including but
* not limited to the correctness, accuracy, reliability or usefulness of
* the software.
*
* Permission to use this software is contingent upon your acceptance
* of the terms of this agreement.
*
*/
package com.sigmatrix.h5.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sigmatrix.h5.dao.DisRebateAuditDao;
import com.sigmatrix.h5.entity.DisRebateAudit;
import com.sigmatrix.h5.utils.SimpleRowMapper;
import com.sigmatrix.h5.web.mode.RebateTotal;
import com.sigmatrix.sc.jdbc.common.dao.DaoImpl;

/**
 *@ClassName: DisRebateAuditDaoImpl
 *@Description: 
 *@author MH
 *@date 2017年8月16日 下午2:02:02
 */
@Repository
public class DisRebateAuditDaoImpl extends DaoImpl<DisRebateAudit,Integer> implements DisRebateAuditDao{

	@Override
	public RebateTotal statisticByDealerAndActivity(Integer dealerId, Short dealerType, Integer activityId) {
		StringBuffer sql = new StringBuffer();
		sql.append("select 	count(1) _count,sum(a._amount) _sum ");
		sql.append("from ").append(tableName()).append(" a ");
		sql.append("where a._dealer_id = ? and a._dealer_type = ? ");
		sql.append("and a._rebate_activity_id = ?");
		List<RebateTotal> list = query(sql.toString(), SimpleRowMapper.createDefault(RebateTotal.class), dealerId,dealerType,activityId);
		return list.get(0);
	}

}
